from rest_framework import serializers
from .models_location import TechnicianLocation, ServiceArea, LocationHistory


class TechnicianLocationSerializer(serializers.ModelSerializer):
    class Meta:
        model = TechnicianLocation
        fields = ['id', 'latitude', 'longitude', 'address', 'updated_at']
        read_only_fields = ['id', 'updated_at']


class ServiceAreaSerializer(serializers.ModelSerializer):
    class Meta:
        model = ServiceArea
        fields = ['id', 'name', 'latitude', 'longitude', 'radius', 'is_active', 'created_at']
        read_only_fields = ['id', 'created_at']


class LocationHistorySerializer(serializers.ModelSerializer):
    class Meta:
        model = LocationHistory
        fields = ['id', 'latitude', 'longitude', 'address', 'created_at']
        read_only_fields = ['id', 'created_at']


class NearbyTechnicianSerializer(serializers.Serializer):
    technician = serializers.DictField()
    latitude = serializers.FloatField()
    longitude = serializers.FloatField()
    distance = serializers.FloatField()
    last_updated = serializers.CharField()
